<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page buffer="48kb"%>
<%@include file="top.jsp" %>
<%@ page import="java.io.*,java.util.*,java.sql.*,java.net.*,java.text.*"%>
<html>
    <head>
        <title>Figure Display</title>
        <meta http-equiv="Content-Type">
        
        <SCRIPT LANGUAGE='JavaScript' SRC='../jsp/SearchResult.js'></SCRIPT>
     
        <style type="text/css">
            <!--
            .figure {
                position:absolute;
                height: 15px;
                width: 342px;
                left: 356px;
                top: 10px;
                font-family:Arial, Helvetica, sans-serif;
                font-size:12px;
            }
            -->
        </style>
    </head>

    <script src="images/prototype.js" type="text/javascript" language="javascript"></script>
    <script src="images/scriptaculous.js" type="text/javascript" language="javascript"></script>

    <script type="text/javascript" src="images/dragdrop.js"></script>
    <script type="text/javascript" src="images/controls.js"></script>
    <script type="text/javascript" src="images/slider.js"></script>
    <script src="images/urchin.js" type="text/javascript">
            <script language="JavaScript" type="text/JavaScript">
         
            <!--
        function MM_preloadImages() { //v3.0
            var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
                var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
                    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
            }
            //-->
              
    </script>
</script>


<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" style="font-family:Arial">
    <form id="pdfForm" name="pdfForm" method="post" action="">
        <input type="hidden" name="rvrCode" value="">
        <input type="hidden" name="userName" value="">
    </form>
    <%
           String id=request.getParameter("id");
            URL server = null;
            try {
                String urlStr = "";               
                urlStr = "http://" + request.getServerName() + ":" + request.getServerPort() + "/HBLPro/Figure";
                server = new URL(urlStr);
            } catch (Exception e) {
                System.out.println("Exception 1 = " + e);
            }
            ObjectInputStream reply = null;
            Object result = null;
            try {
                URLConnection con = server.openConnection();
                con.setDoInput(true);
                con.setDoOutput(true);
                con.setUseCaches(false);
                con.setRequestProperty("Content-Type", "application/octet-stream");
                con.setAllowUserInteraction(false);
                ObjectOutputStream command =
                        new ObjectOutputStream(
                        new BufferedOutputStream(con.getOutputStream()));
                command.writeObject("getRealPath");
                command.flush();
                command.close();
                ObjectInputStream in = new ObjectInputStream(con.getInputStream());
                result = in.readObject();
                in.close();
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("Exception 2 = " + e);
            }
            String path ="http://" + request.getServerName() + ":" + request.getServerPort() + "/HBLPro/Figure";

            String imagePath = "";         
            imagePath = path+ "/"+id;
            System.out.println(imagePath);
            java.awt.Image img = null;
            try {
                img = javax.imageio.ImageIO.read(new File(imagePath));
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
            int imgWidth = 2000;
            int imgHeight = 1500;
            if (img != null) {
                imgWidth = img.getWidth(null);
                imgHeight = img.getHeight(null);

            }

    %>
    <form action="figureDisplaySearch.jsp" method="post" id="formImg">
        <input type="hidden"  name="jsParam" id="jsParam">
    </form>
    <div id="content-c">
        <div class="post">
            <div class="entrytext">
                <div style="margin: 10px 0pt 10px 100px;">
                    <div id="track1" style="margin: 4px 0pt 0pt 10px; width: 200px; background-image: url(images/scaler_slider_track.gif); background-repeat: repeat-x; background-position: left center; height: 18px;">
                        <div class="selected" id="handle1" style="width: 18px; height: 18px; left: 6px; position: relative;"><img src="images/scaler_slider.gif"></div>
                    </div>
                    
                    
                </div>
                <br>
                <br>
                <div>
                        <img name="fig" id="fig" src="<%=path%>/<%=id%>" >
                </div>
                <script language="javascript">
                        var img=document.getElementById("fig");
                        //alert(img.width+":"+img.height);
                        var imgWidth=<%=imgWidth%>;
                        var imgHeight=<%=imgHeight%>;
					
                        zoomVal.value=Math.round((950.00/imgWidth)*100);
					
                        img.style.width = 950+"px";
                </script>
                <script type="text/javascript" src="images/scale_demo.js"></script>


            </div>
        </div>
    </div>
</body>

</html>